package cn.zc.curriculum.service.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.model.ObjectMetadata;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;


import java.util.Set;

@Data
@Configuration
@PropertySource("classpath:uploadConfig.properties")
@ConfigurationProperties(prefix = "upload-config")
public class UploadConfig {

    private String aliOssEndpoint;
    // 阿里云账号AccessKey拥有所有API的访问权限，风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维，请登录RAM控制台创建RAM用户。
    private  String aliOssAccessKeyId;
    private String aliOssAccessKeySecret;
    // 填写Bucket名称，例如examplebucket。
    private  String aliOssbucketName;
    // 填写Object完整路径，例如exampledir/exampleobject.txt。Object完整路径中不能包含Bucket名称。
    private  String aliOssObjectName ;
    //保存本地路径点
    private  String localSavePath;
    //视频后缀白名单
    private Set<String> videoEnd;
    //图片后缀白名单
    private Set<String> imgEnd;
    //默认oss路径
    private String aliOssUrl;
    //图片是否保存本地
    private  boolean imgLocalSave;
    //视频是否保存本地
    private boolean videoLocalSave;
    //图片是否保存至Oss
    private boolean imgOssSave;
    //视频是否保存Oss
    private boolean videoOssSave;
    //视频是否保存至保宁威视
    private boolean videoBlwsSave;


    //创建oss
    public OSS getOss(){
       return new OSSClientBuilder().build(aliOssEndpoint, aliOssAccessKeyId, aliOssAccessKeySecret);
    }

    //设定格式
    public ObjectMetadata getImgMetaData(){
        ObjectMetadata objectMetadata = new ObjectMetadata();
        objectMetadata.setContentType("image/jpg");
        return objectMetadata;
    }


}
